﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using IndoReputation.Models.BusinessObject;
using IndoReputation.Models.BusinessObject.Collections;
using IndoReputation.Models.DataAccess;

namespace IndoReputation.Models.BusinessLogic
{
    public class NewsCategoryBOL
    {
        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 4/22/2012  6:03 PM
        /// Todo: Insert an newsCategory to db
        /// </summary>
        /// <param name="newsCategory">The newsCategory.</param>
        /// <returns></returns>
        public static int Insert(NewsCategory newsCategory)
        {
            try
            {
                newsCategory.CreateAt = DateTime.Now;
                newsCategory.CreateBy = MySession.UserID;
                newsCategory.UpdateAt = null;
                newsCategory.UpdateBy = null;
                return NewsCategoryDAL.Insert(newsCategory);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  9:45 AM
        /// Todo: Update a User Exists in Database 
        /// </summary>
        /// <param name="newsCategory">A newsCategory.</param>
        /// <returns></returns>
        public static bool Update(NewsCategory newsCategory)
        {
            try
            {
                newsCategory.UpdateAt = DateTime.Now;
                newsCategory.UpdateBy = MySession.UserID;
                return NewsCategoryDAL.Update(newsCategory);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  10:36 AM
        /// Todo: Delete a User Existst in Database
        /// </summary>
        /// <param name="newsCategory">A newsCategory.</param>
        /// <returns></returns>
        public static bool Delete(int newsCategoryID)
        {
            try
            {
                return NewsCategoryDAL.Delete(newsCategoryID);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/29/2011  5:23 PM
        /// Todo: Get All NewsCategory
        /// </summary>
        /// <returns></returns>
        public static NewsCategoryList GetAllNewsCategory()
        {
            try
            {
                return NewsCategoryDAL.GetAllNewsCategory() ?? new NewsCategoryList();
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  10:40 AM
        /// Todo: Select a User existst in Database
        /// </summary>
        /// <param name="newsCategoryID">The newsCategory ID.</param>
        /// <returns></returns>
        public static NewsCategory GetNewsCategoryById(int newsCategoryID)
        {
            try
            {
                return NewsCategoryDAL.GetNewsCategoryById(newsCategoryID);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/29/2011  5:23 PM
        /// Todo: Get All NewsCategory
        /// </summary>
        /// <returns></returns>
        public static NewsCategoryJoinList GetAllNewsCategoryJoin()
        {
            try
            {
                return NewsCategoryDAL.GetAllNewsCategoryJoin() ?? new NewsCategoryJoinList();
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
    }
}